package com.goods.shop.exam;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class E10131 {
    public void print(int num){
        int[][] ctrix=new int[num][num];
        int index1=0,index2=num-1;
        String direction="D";
        int index=0;
        int currentNum=1;
        while(currentNum<=num*num){
            switch(direction){
                case "D":
                    if(index1==num||ctrix[index1][index2]!=0){
                        direction="L";
                        index1--;//偏移一下
                        index2--;
                        break;
                    }
                    ctrix[index1][index2] = currentNum;
                    index1++;
                    currentNum++;

                    break;
                case "L":
                    if(index2==-1||ctrix[index1][index2]!=0){
                        direction="U";
                        index1--;//向上减少
                        index2++;
                        break;
                    }
                    ctrix[index1][index2] = currentNum;
                    index2--;
                    currentNum++;
                    break;
                case "U":
                    if(index1==-1||ctrix[index1][index2]!=0){
                        direction="R";
                        index2++;//向右
                        index1++;
                        break;
                    }
                    ctrix[index1][index2] = currentNum; ;
                    index1--;
                    currentNum++;
                    break;
                case "R":
                    if(index2==num||ctrix[index1][index2]!=0){
                        direction="D";
                        index1++;//向下
                        index2--;
                        break;
                    }
                    ctrix[index1][index2] =currentNum; ;
                    index2++;
                    currentNum++;
                    break;
            }
        }
        for(int i=0;i<num;i++){
            for(int j=0;j<num;j++){
                System.out.print(ctrix[i][j]);
                if(j!=num-1) System.out.print(" ");
            }
            System.out.println();
        }
    }

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        E10131 service=new E10131();
        List<Integer> datas=new ArrayList<>();
        int data=scanner.nextInt();
        service.print(data);

    }
}
